from pms.common.views import PostFormula
from user.utils.list import all_users


class API(PostFormula):

    def handle(self, req):
        users = all_users()
        users_list = [{
            'id': user.id,
            'name': user.name,
            'role': {
                'id': user.rid.id,
                'name': user.rid.name
            }
        } for user in users]
        return self.success_respond({
            'list': users_list
        })
